package com.cskaoyan.day7;

public class AccountTest {
    public static void main(String[] args) {
        Account account = new Account(100000);
        System.out.println(account.toString());
        account.annualInterest();
        System.out.println(account.toString());
        System.out.println(new Account(100000).toString());
        System.out.println(new Account(100000).toString());
        System.out.println(new Account(100000).toString());
    }
}

class Account {
    private int id = 10000;
    private String password = "000000";
    private double balance;
    private double annualRate = 0.3;
    static int count = 0;

    public Account(double balance) {
        this.balance = balance;
        id += ++Account.count;
    }

    @Override
    public String toString() {
        return "Account{" +
                "id=" + id +
                ", password='" + password + '\'' +
                ", balance=" + balance +
                ", annualRate=" + annualRate +
                '}';
    }

    public double annualInterest() {
        balance = balance * (1 + annualRate * 0.01);
        return balance;
    }
}